package demo5;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 98152
 * Date: 2024-05-27
 * Time: 16:43
 */
class MyThread implements Runnable {
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName() + "运行->"+i);
        }
    }
}
public class ThreadJoinDemo {
    public static void main(String[] args) {
        MyThread mt = new MyThread();
        Thread t = new Thread(mt,"线程");
        t.start();
        for (int i = 0; i < 5; i++) {
            if(i > 3) {
                try{
                    t.join();
                }catch (Exception e) {

                }
                System.out.println("Main 线程运行 ->" + i);
            }
        }
    }
}
